package responsehandler;

import java.io.IOException;
import java.net.ServerSocket;
import java.sql.Connection;

import properties.Properties;

public class ResponseHandler implements Runnable {

	Connection con;

	public ResponseHandler(Connection con) {
		this.con = con;
	}

	@Override
	public void run() {
		try {
			ServerSocket serversocket = new ServerSocket(Properties.getProperties().getPort());
			System.out.println("Online: Waiting for client");

			while (true) {
				try {
					ClientThread ct = new ClientThread(serversocket.accept(), con);
					System.out.println("Connecting");
					Thread t = new Thread(ct);
					t.start();
				} catch (Exception e) {
					System.out.print(e);
					System.exit(-1);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
